/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import model.*;
import javax.swing.*;
import java.awt.*;

/**
 *
 * @author Benjamin De Clercq, Michiel Vancoillie, Ruben Slabbinck
 */
public class KeuzeVak extends JLabel {

    private final Color KLEUR = Color.WHITE;

    private Pion pion;
    private int aantal;

    public KeuzeVak(Pion pion, int aantal) {
        this.pion = pion;
        this.aantal = aantal;

        setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        setOpaque(true);
        setBackground(KLEUR);
    }

    public int getAantal() {
        return aantal;
    }

    public void minusOne() {
        aantal--;
        repaint();
    }

    public Pion getPion() {
        return pion;
    }

    public void selecteer(){
        setBackground(KLEUR.darker());
    }

    public void deselecteer(){
        setBackground(KLEUR);
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

        Graphics2D g2=(Graphics2D)g;
       if (aantal > 0) {
            ImageIcon afbeelding = pion.getImageIcon();
            afbeelding.paintIcon(this, g2, (this.getWidth() - afbeelding.getIconWidth()) / 2, (this.getHeight() - afbeelding.getIconHeight()) / 2);
            g2.setColor(Color.BLACK);
            g2.drawString(aantal + "", 10, 20);
       }
    }

}
